#ifndef TICKCOUNTRUNNABLE_HPP
#define TICKCOUNTRUNNABLE_HPP

#include <QThread>
#include <QtCore/QMutex>
#include <QtCore/QMutexLocker>
#include <QtCore/QDebug>


/**
 * @brief Abstract super class for all TickCount Runnables (unix / win)
 * @details The runnables will use the PerformanceCounters under Windows or GetTickCount in Unix to determine
 * the deviation of an msleep
 *
 * @class TickCountRunnable tickcountrunnable.hpp "tickcountrunnable.hpp"
*/
class TickCountRunnable : public QThread
{
    Q_OBJECT
public:
    /**
     * @brief Default Constructor
     *
     * @fn TickCountRunnable
     * @param parent
    */
    explicit TickCountRunnable (QObject *parent = 0);

    /**
     * @brief Stop the execution of the Thread
     * @details Will set the m_isRunning member variable to false.
     * This will cause the run function to exit on next iteration
     *
     * @fn stop
    */
    void stop();

    /**
     * @brief Get the internal state of the Thread
     * @details Returns true if the Thread is currently running
     * Returns false if the Thread is not running or has been stopped and performs its last iteration
     *
     * @fn getIsRunning
     * @return bool
    */
    bool getIsRunning();

protected:
    /**
     * @brief Set the internal state of the Thread
     *
     * @fn setIsRunning
     * @param state
    */
    void setIsRunning(bool state);

private:
    QMutex m_mutex;
    volatile bool m_isRunning;

protected:
    int m_waitInterval;
};

#endif // TICKCOUNTRUNNABLE_HPP
